<?php
// $Id: hotel.php 433 2012-06-05 23:39:56Z tomqin@gmail.com $

defined('IN_ADMIN') or exit('Access Denied!');

class Hotel_Action extends Action_Admin{

    public function init(){
        parent::init();
        $this->shop_id = intval($this->params);
        $this->setVar('shop_id', $this->shop_id);

        $this->hotel = App::module('table_hotel', 'table', array($this->user));
        if(!$this->hotel->check_user_right($this->shop_id)){
            $this->renderDialog('您无权管理此商铺信息！');
        }
    }

    public function onModify(){
        $cats = array(
            1 => '五星酒店', '四星酒店', '三星酒店', '二星酒店', '特色餐饮', '庄园会所', '主题会所', '游轮婚宴'
        );
        $tags = array(
            9 => '户外草坪', '自助餐', '特色西餐', '中式庭院', '清真婚宴', '主题餐厅', '楼顶花园', '无柱厅'
        );

        $this->setVar('cats', $cats);
        $this->setVar('tags', $tags);
        $this->setVar('show_validator', 1);

        if($this->shop_id){
            $hotel = $this->hotel->get_data($this->shop_id);
            if($hotel){
                $hotel['tags'] = explode(',', $hotel['tags']);
                $this->setVar('data', $hotel);
                $this->render('admin/hotel/edit');
            }else{
                $this->renderDialog('酒店信息不存在，无法读取信息！');
            }
        }
    }

    public function onSave(){
        if(array_get_bool($_POST, 'dosubmit')){
            switch(array_get_string($_POST, 'method')){
                case 'modify':
                    $this->hotel->update($this->shop_id, $_POST);
                    $this->renderDialog('修改成功！', '/admin/hotel/modify/'.$this->shop_id);
                break;
            }
        }else{
            $this->renderDialog('无效的参数！');
        }
    }

    function __destruct(){}
}
?>